#ifndef _MAN_UI_H_
#define _MAN_UI_H_

#include <stdio.h>
#include <strings.h>
#include <thread>
#include <iostream>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <vector>
#include "common.hpp"

#define MAN_OP "  >>>>>>>>>>  [left: next page]  [right: previous page]  [q: quit]"
#define MAN_LINESIZE  20

using namespace std;

class ManShellUI {
public:
	ManShellUI();
	ManShellUI(string titel);
	~ManShellUI();
	void start();
	void start(string fifo);
	void setResult(string result);
	void setPage(int page);
	void setPageMax(int count);
	int  getPage();
	void clearResult();
	void setTitel(string titel);
	void loop();
	void loopFIFO();
	void update();

private:
	static void threadFunc(ManShellUI* ptr);
	static void threadFuncFIFO(ManShellUI* ptr);
	bool m_quit;
	int m_fifo;
	void m_init();
	thread m_thread;
	thread m_threadfifo;
	string m_titel;
	string m_result;
	int m_max;
	unsigned int m_page;
};

#endif
